package com.fingard.dsp.bank.directbank.bos01;

import com.fingard.FGBiz;
import com.fingard.constant.Format;
import com.fingard.db.JDBCHelper;
import com.fingard.dsp.bank.directbank.bankInterface.IElecBillTrans;
import com.fingard.dsp.bank.reqrespobj.elecbilltrans.*;
import com.fingard.dsp.bank.reqrespobj.elecbilltrans.detail.*;
import com.fingard.util.DateHelper;
import com.fingard.xml.XmlTextReader;
import com.fingard.xml.XmlTextWriter;

import java.sql.Connection;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

public class BOS01ElecBillTrans extends BOS01Base implements IElecBillTrans {

    /**
     * 通用签收
     */
    @Override
    public RetAtsB003BillRespSubmit D_B003_BillResp_Submit(ReqB003BillRespSubmit query) throws Exception{
        RetAtsB003BillRespSubmit retAts=new RetAtsB003BillRespSubmit(query.reqHeader);
        RetAtsB003BillRespSubmitDetail detail=new RetAtsB003BillRespSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForDraftSign1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdcustacc", query.detail.actNum);//签约账号
            xmlWriter.writeElementString("Stdbillnum", query.detail.billNo);//票号
            xmlWriter.writeElementString("Stdbusstyp", getStdinfotypByRespType(query.detail.respType,query.detail.proPayType));//业务类型
            xmlWriter.writeElementString("Stdbussqno", "",true);//业务流水标识
            xmlWriter.writeElementString("Stdsgnrres", getRespFlag(query.detail.respFlag),true);//签收结果
            xmlWriter.writeElementString("Stdsgnrrat", query.detail.accpCredit,true);//签收人信用登记
            xmlWriter.writeElementString("Stdsgnrgcy", query.detail.accpGrade,true);//签收人评级机构
            xmlWriter.writeElementString("Stdsgradat", DateHelper.convertD10toD8(query.detail.accpGradeDue),true);//签收人评级到期日
            if("6".equals(query.detail.respType) && "2".equals(query.detail.respFlag)){
                xmlWriter.writeElementString("Stddshnrcd", getStddshnrcdByUnPayCode(query.detail.unPayCode),true);//拒付理由
            }else {
                xmlWriter.writeElementString("Stddshnrcd", "",true);//拒付理由
            }
            xmlWriter.writeElementString("Stddshnrsn", query.detail.unPayMemo,true);//拒付备注
            xmlWriter.writeElementString("Reserve1", "",true);//备用字段1
            xmlWriter.writeElementString("Reserve2", "",true);//备用字段2
            xmlWriter.writeElementString("Reserve3", "",true);//备用字段3
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 出票 ok

     */
    @Override
    public RetAtsB101BillApplySubmit D_B101_BillResp_Submit(ReqB101BillApplySubmit query) throws Exception{
        RetAtsB101BillApplySubmit retAts=new RetAtsB101BillApplySubmit(query.reqHeader);
        RetAtsB101BillApplySubmitDetail detail=new RetAtsB101BillApplySubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForRegister1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdpmmoney", query.detail.billAmt);//票面金额
            xmlWriter.writeElementString("Stdbilltyp", getBillType(query.detail.billType));//票据类型  AC01银承 AC02商承
            xmlWriter.writeElementString("Stdissdate", DateHelper.convertD10toD8(query.detail.issDate));//出票日YYYYMMDD
            xmlWriter.writeElementString("Stdduedate", DateHelper.convertD10toD8(query.detail.dueDate));//到期日YYYYMMDD
            xmlWriter.writeElementString("Stddrwracc", query.detail.drawAct);//出票人账号
            xmlWriter.writeElementString("Stdaccpnam", query.detail.accpName,true);//承兑人名称
            xmlWriter.writeElementString("Stdaccpacc", "1".equals(query.detail.billType)?"":query.detail.accpAct,true);//承兑人账号
            xmlWriter.writeElementString("Stdaccpbnm", query.detail.accpBnkCode,true);//承兑人行号
            xmlWriter.writeElementString("Stdendormk", getTransFlag(query.detail.transFlag),true);//转让标志 EM00可再转让 EM01不得转让
            xmlWriter.writeElementString("Stdpyeenam", query.detail.payeeName,true);//收款人名称
            xmlWriter.writeElementString("Stdpyeeacc", query.detail.payeeAct,true);//收款人账号
            xmlWriter.writeElementString("Stdpyeebnm", query.detail.payeeBnkCode,true);//收款人开户行行号
            xmlWriter.writeElementString("Stdcontrnm", query.detail.contractNo,true);//合同编号
            xmlWriter.writeElementString("Stdinvcnum", query.detail.invoiceNo,true);//发票号码
            xmlWriter.writeElementString("Stddrcdrat", query.detail.creditLv,true);//信用等级
            xmlWriter.writeElementString("Stddrragcy", query.detail.gradeAgent,true);//评级机构
            xmlWriter.writeElementString("Stdrduedat", DateHelper.convertD10toD8(query.detail.gradeDueDate),true);//评级到期日
            xmlWriter.writeElementString("Stddrwrmem", query.detail.memo,true);//出票登记备注
            xmlWriter.writeElementString("Reserve1", "",true);//备用字段
            xmlWriter.writeElementString("Reserve2", "",true);//备用字段
            xmlWriter.writeElementString("Reserve3", "",true);//备用字段
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 提示承兑 ok

     * */
    @Override
    public RetAtsB102BillAccpSubmit D_B102_BillResp_Submit(ReqB102BillAccpSubmit query) throws Exception{
        RetAtsB102BillAccpSubmit retAts=new RetAtsB102BillAccpSubmit(query.reqHeader);
        RetAtsB102BillAccpSubmitDetail detail=new RetAtsB102BillAccpSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForAccept1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdcustacc", query.detail.actNum);//签约账号
            xmlWriter.writeElementString("Stdbillnum", query.detail.billNo);//票号
            xmlWriter.writeElementString("Stdautoprompt", "01");//是否自动提示收票 01是 02否
            xmlWriter.writeElementString("Remark", query.detail.memo,true);//备注
            xmlWriter.writeElementString("Reserve1", "",true);//备用字段
            xmlWriter.writeElementString("Reserve2", "",true);//备用字段
            xmlWriter.writeElementString("Reserve3", "",true);//备用字段
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 撤票 ok
     * @param query
     * @return
     * @throws Exception
     */
    @Override
    public RetAtsB103BillRetSubmit D_B103_BillResp_Submit(ReqB103BillRetSubmit query) throws Exception {
        RetAtsB103BillRetSubmit retAts=new RetAtsB103BillRetSubmit(query.reqHeader);
        RetAtsB103BillRetSubmitDetail detail=new RetAtsB103BillRetSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForDraftCancel1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdcustacc", query.detail.actNum);//签约账号
            xmlWriter.writeElementString("Stdbillnum", query.detail.billNo);//票号
            xmlWriter.writeElementString("Stdrvkrtyp", "01");//01-未用退回 02-指令撤销
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 提示收票 ok

     */
    @Override
    public RetAtsB104BillReceSubmit D_B104_BillResp_Submit(ReqB104BillReceSubmit query) throws Exception {
        RetAtsB104BillReceSubmit retAts=new RetAtsB104BillReceSubmit(query.reqHeader);
        RetAtsB104BillReceSubmitDetail detail=new RetAtsB104BillReceSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForIssuanceRequest1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdcustacc", query.detail.actNum);//签约账号
            xmlWriter.writeElementString("Stdbillnum", query.detail.billNo);//票号
            xmlWriter.writeElementString("Remark", query.detail.memo,true);//备注
            xmlWriter.writeElementString("Reserve1", "",true);//备用字段
            xmlWriter.writeElementString("Reserve2", "",true);//备用字段
            xmlWriter.writeElementString("Reserve3", "",true);//备用字段
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 背书转让申请 ok
     */
    @Override
    public RetAtsB105BillEndoSubmit D_B105_BillResp_Submit(ReqB105BillEndoSubmit query) throws Exception{
        RetAtsB105BillEndoSubmit retAts=new RetAtsB105BillEndoSubmit(query.reqHeader);
        RetAtsB105BillEndoSubmitDetail detail=new RetAtsB105BillEndoSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForNegotiablity1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdcustacc", query.detail.actNum);//签约账号
            xmlWriter.writeElementString("Stdbillnum", query.detail.billNo);//票号
            xmlWriter.writeElementString("Stdbanmflg", getTransFlag(query.detail.transFlag));//转让标识
            xmlWriter.writeElementString("Stdendeacc", query.detail.receAct);//被背书人账号
            xmlWriter.writeElementString("Stdendenam", query.detail.receName);//被背书人名称
            xmlWriter.writeElementString("Stdendebnm", query.detail.receBnkCode);//被背书人行号
            xmlWriter.writeElementString("Remark", query.detail.memo,true);//备注
            xmlWriter.writeElementString("Reserve1", "",true);//备用字段
            xmlWriter.writeElementString("Reserve2", "",true);//备用字段
            xmlWriter.writeElementString("Reserve3", "",true);//备用字段
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 贴现申请 ok 默认均为买断式贴现，回购式银企直接不支持

     */
    @Override
    public RetAtsB106BillDiscSubmit D_B106_BillResp_Submit(ReqB106BillDiscSubmit query) throws Exception{
        RetAtsB106BillDiscSubmit retAts=new RetAtsB106BillDiscSubmit(query.reqHeader);
        RetAtsB106BillDiscSubmitDetail detail=new RetAtsB106BillDiscSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForDiscount1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdcustacc", query.detail.actNum);//签约账号
            xmlWriter.writeElementString("Stdbillnum", query.detail.billNo);//票号
            xmlWriter.writeElementString("Stdintemtd", getPayInterestTypeToBank(query.detail.payInterestType),true);//付息方式
            xmlWriter.writeElementString("Stdstlmthd", getPayType(query.detail.payType));//清算标识 SM00线上清算 SM01线下清算
            xmlWriter.writeElementString("Stddsbkbnm", query.detail.receBnkCode,true);//贴入人行号
            xmlWriter.writeElementString("Stddsbknme", query.detail.receBnkName,true);//贴入人行名
            xmlWriter.writeElementString("Stddscntrt", query.detail.discRate,true);//贴现利率
            xmlWriter.writeElementString("Stdrealamt", query.detail.discAmt,true);//实付金额
            xmlWriter.writeElementString("Stdaoaiacc", query.detail.actedAct,true);//入账账号
            xmlWriter.writeElementString("Stdaoaibnm", query.detail.actedBnkCode,true);//入账行号
            xmlWriter.writeElementString("Stdcontnum", query.detail.contractNo,true);//交易合同号
            xmlWriter.writeElementString("Stdinvonum", query.detail.invoiceNo,true);//发票号码
            xmlWriter.writeElementString("StdPaydscntrt", query.detail.payInterestRate,true);//付息比例
            xmlWriter.writeElementString("StdPayaoaiacc", query.detail.payInterestAct,true);//第三方付息账号
            xmlWriter.writeElementString("Std400memo", query.detail.memo,true);//备注
            xmlWriter.writeElementString("Reserve1", "",true);//备用字段
            xmlWriter.writeElementString("Reserve2", "",true);//备用字段
            xmlWriter.writeElementString("Reserve3", "",true);//备用字段
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 质押申请 不支持

     */
    @Override
    public RetAtsB107BillPledSubmit D_B107_BillResp_Submit(ReqB107BillPledSubmit query) throws Exception{
        RetAtsB107BillPledSubmit retAts=new RetAtsB107BillPledSubmit(query.reqHeader);
        retAts.writeBeforeDetail();
        RetAtsB107BillPledSubmitDetail detail=new RetAtsB107BillPledSubmitDetail();
        detail.respCode="-1";
        detail.respInfo="银行暂不支持此操作";
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 提示付款 ok

     */
    @Override
    public RetAtsB108BillPaySubmit D_B108_BillResp_Submit(ReqB108BillPaySubmit query) throws Exception{
        RetAtsB108BillPaySubmit retAts=new RetAtsB108BillPaySubmit(query.reqHeader);
        RetAtsB108BillPaySubmitDetail detail=new RetAtsB108BillPaySubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            BOS01Header tmpHeader = new BOS01Header();
            tmpHeader.opName = "BillsForPayment1_1Op";
            tmpHeader.serialNo = query.detail.reqSeqID;
            tmpHeader.needSigned = true;
            XmlTextWriter xmlWriter = new XmlTextWriter();
            writeCommonHeader(xmlWriter, tmpHeader);
            xmlWriter.writeElementString("Stdprsnacc", query.detail.actNum);//签约账号
            xmlWriter.writeElementString("Stdbillnum", query.detail.billNo);//票号
            xmlWriter.writeElementString("Stdbusstyp", "0"+query.detail.proPayType,true);//提示付款类型
            xmlWriter.writeElementString("Stdsttlflg", getPayType(query.detail.payType),true);//清算标识 SM00线上清算 SM01线下清算
            xmlWriter.writeElementString("Std400memo", query.detail.memo,true);//备注
            xmlWriter.writeElementString("Reserve1", "",true);//备用字段
            xmlWriter.writeElementString("Reserve2", "",true);//备用字段
            xmlWriter.writeElementString("Reserve3", "",true);//备用字段
            xmlWriter.writeEndDocument();
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(), tmpHeader);
            RetAtsCommonSubmitDetail commonSubmitDetaildetail=getRspResultCode(tmpStrRet,query.detail.reqSeqID,query.reqHeader.bankCode);
            detail.respCode=commonSubmitDetaildetail.respCode;
            detail.respInfo=commonSubmitDetaildetail.respInfo;
            detail.transState=commonSubmitDetaildetail.transState;
            detail.payInfoCode=commonSubmitDetaildetail.payInfoCode;
            detail.reqSeqID=commonSubmitDetaildetail.reqSeqID;
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 保证申请

     */
    @Override
    public RetAtsB109BillGuarSubmit D_B109_BillResp_Submit(ReqB109BillGuarSubmit query) throws Exception{
        RetAtsB109BillGuarSubmit retAts=new RetAtsB109BillGuarSubmit(query.reqHeader);
        retAts.writeBeforeDetail();
        RetAtsB109BillGuarSubmitDetail detail=new RetAtsB109BillGuarSubmitDetail();
        detail.respCode="-1";
        detail.respInfo="银行暂不支持此操作";
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 追索通知

     */
    @Override
    public RetAtsB110BillRecoSubmit D_B110_BillResp_Submit(ReqB110BillRecoSubmit query) throws Exception{
        RetAtsB110BillRecoSubmit retAts=new RetAtsB110BillRecoSubmit(query.reqHeader);
        retAts.writeBeforeDetail();
        RetAtsB110BillRecoSubmitDetail detail=new RetAtsB110BillRecoSubmitDetail();
        detail.respCode="-1";
        detail.respInfo="银行暂不支持此操作";
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 同意清偿

     */
    @Override
    public RetAtsB111BillAgreeSubmit D_B111_BillResp_Submit(ReqB111BillAgreeSubmit query) throws Exception{
        RetAtsB111BillAgreeSubmit retAts=new RetAtsB111BillAgreeSubmit(query.reqHeader);
        retAts.writeBeforeDetail();
        RetAtsB111BillAgreeSubmitDetail detail=new RetAtsB111BillAgreeSubmitDetail();
        detail.respCode="-1";
        detail.respInfo="银行暂不支持此操作";
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 交易撤回

     */
    @Override
    public RetAtsB112BillCancSubmit D_B112_BillResp_Submit(ReqB112BillCancSubmit query) throws Exception{
        RetAtsB112BillCancSubmit retAts=new RetAtsB112BillCancSubmit(query.reqHeader);
        retAts.writeBeforeDetail();
        RetAtsB112BillCancSubmitDetail detail=new RetAtsB112BillCancSubmitDetail();
        detail.respCode="-1";
        detail.respInfo="银行暂不支持此操作";
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 协议出票
     */
    @Override
    public RetAtsB113ProtocolSubmit D_B113_ProtocolResp_Submit(ReqB113ProtocolSubmit query) throws Exception {
        RetAtsB113ProtocolSubmit retAts=new RetAtsB113ProtocolSubmit(query.reqHeader);
        retAts.writeBeforeDetail();
        RetAtsB113ProtocolSubmitDetail detail=new RetAtsB113ProtocolSubmitDetail();
        detail.respCode="-1";
        detail.respInfo="银行暂不支持此操作";
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    @Override
    public RetAtsB119BillRelePledSubmit D_B119_BillResp_Submit(ReqB119BillRelePledSubmit query) throws Exception {
        return null;
    }

    /**
     * 操作票据响应结果统一处理
     * @param tmpStrRet
     * @param reqSeqID
     * @param bankCode
     * @return
     * @throws Exception
     */
    private RetAtsCommonSubmitDetail getRspResultCode(String[] tmpStrRet,String reqSeqID,String bankCode) throws Exception{
        RetAtsCommonSubmitDetail detail=new RetAtsCommonSubmitDetail();
        Connection conn= null;
        try{
            if (tmpStrRet[0].length() == 0) {
                StringBuilder tmpSbMsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
                if (tmpBkReader != null) {
                    String tmprspcod = tmpBkReader.getFirstText("/BOSEBankData/opRep/retCode");
                    String tmprspmsg = tmpBkReader.getFirstText("/BOSEBankData/opRep/errMsg");
                    detail.respCode = "0";
                    detail.respInfo = tmprspcod+"+"+tmprspmsg;
                    String bankSeqId=tmpBkReader.getFirstText("/BOSEBankData/opRep/opResult/Stdtrannum");//银行流水号
                    conn=FGBiz.getLocalDbConn();
                    Map<String, Object> selMap= JDBCHelper.execQuerySingle(conn,SELECTSEQ,new Object[]{reqSeqID,bankCode,"8"});
                    if(selMap.size()==0){
                        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                        JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, bankCode, Format.Date8Format.format(new Date()), reqSeqID, bankSeqId,"8"});
                    }
                    detail.reqSeqID = reqSeqID;
                    detail.transState = "0".equals(tmprspcod)?tmprspcod:"others";
                    detail.payInfoCode = detail.transState;
                    if (tmprspmsg.contains("非法SESSION") || tmprspmsg.contains("SESSION已超时")) {
                        bankFront.token = "";
                    }
                } else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpSbMsg.toString();
                }
            } else {
                detail.respCode = "-1";
                detail.respInfo = tmpStrRet[1];
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if(conn!=null){
                conn.close();
            }
        }
        return detail;
    }
}
